package controller;

import javax.microedition.midlet.MIDlet;

import util.MoneyControlConstants;
import view.ManageBanks;

import com.sun.lwuit.Button;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;

public class MenuHandler implements ActionListener
{
	private MIDlet midlet;
	
	public MenuHandler(MIDlet m)
	{
		this.midlet = m;
	}
	
	public void actionPerformed(ActionEvent e)
	{
		
		if( ( (Button) e.getSource()).getText().equals(MoneyControlConstants.TEXT_MENU_ITEM_QUIT) )
		{
			this.midlet.notifyDestroyed();
		}
		else if( ( (Button) e.getSource()).getText().equals(MoneyControlConstants.TEXT_MENU_ITEM_BANKS) )
		{
			MoneyControl mc = (MoneyControl) this.midlet;
			mc.setForm(new ManageBanks(this.midlet));
		}
		
	}

	public MIDlet getMidlet()
	{
		return midlet;
	}

	public void setMidlet(MIDlet midlet)
	{
		this.midlet = midlet;
	}
	
}
